/*
 * A simple ToDo Manager
 *
 * Copyright (c) 2011 Nosheen Zaza, Manuel Rebollo, Seyedsaeid Mahpeikar and
 * Wo Ke
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package todomanager.model;

import java.util.GregorianCalendar;;

/**
 * A representation of a task data type, with methods to set up a task and get
 * its properties.
 * 
 * @author Manuel Rebollo
 * @author Nosheen Zaza
 */
public class Task {
    /**
     * task ids are runtime-only ids. This makes task deletion less messy.
     * A task's id is its position in a list.
     */
    private int id;
    private String category;
    private boolean done;
    private String text;
    private int progress;

    /**
     * Date fields are not mandatory, as we want to allow the user to enter
     * simple tasks that do not need a due date (e.g buy milk.)
     */
    private GregorianCalendar dueDate;
    private String priority;

    /**
     * Creates a new task instance with no fields initialized.
     */
    public Task() {
    }

    /**
     * Creates a new task instance, the task is marked as undone.
     * @param id id of the task.
     * @param text text of the task.
     */
    public Task(int id, String text) {
        this.id = id;
        this.done = false;
        this.text = text;
        this.progress = 0;
    }

    public Task(int id, String text, int year, int month, int day) {
        this(id, text);
        dueDate = new GregorianCalendar(year, month, day);
    }

    public Task(int id, String text, String category, String priority) {
        this(id, text);
        this.priority = priority;
        this.category = category;
    }
 
    public Task(int id, String text, String category, String priority, int year, int month, int day) {
    	this(id, text);
	    this.priority = priority;
	    this.category = category;
            dueDate = new GregorianCalendar(year, month, day);
    }
 
    /**
     * Returns a task's text.
     * @return text: a task's text.
     */
    public String getText() {
        return text;
    }

    /**
     * Sets a task's text.
     * @param text
     */
    public void setText(String text) {
        String oldText = this.text;
        this.text = text;
    }

    /**
     * Returns a task's status.
     * @return done: a task's status
     */
    public boolean isDone() {
        return done;
    }

    /**
     * Sets the status of a task.
     * @param done
     */
    public void setDone(boolean done) {
        this.done = done;
    }

    /**
     * Returns a task's id.
     * @return id
     */
    public int getId() {
        return id;
    }

    /**
     * Sets a task's id.
     * @param id a task's id.
     */
    public void setId(int id) {
        this.id = id;
    }

    /**
     * Returns a task's category.
     * @return category: a task's category.
     */
    public String getCategory() {
        return category;
    }

    /**
     * Sets a task's category.
     * @param category
     */
    public void setCategory(String category) {
        this.category = category;
    }

    /**
     * Sets a task's progress to the given one.
     * @param progress
     */
    public void setProgress(int progress) {
        this.progress = progress;
    }

    /**
     * returns a tasks progress.
     * @return progress
     */
    public int getProgress() {
        return progress;
    }

   /**
    * Returns a task's priority.
    * @return priority
    */
    public String getPriority() {
        return priority;
    }

    /**
     * Sets a task's priority.
     * @param priority
     */
    public void setPriority(String priority) {
        this.priority = priority;
    }

    /**
     * Returns a task's due date.
     * @return
     */
    public GregorianCalendar getDueDate() {
        return dueDate;
    }

    /**
     * Sets a task's due date.
     * @param dueDate
     */
    public void setDueDate(GregorianCalendar dueDate) {
        this.dueDate = dueDate;
    }
}
